package com.dk.service.impl;

import com.dk.mapper.TbUserScoreAccountMapper;
import com.dk.pojo.TbUserScoreAccount;
import com.dk.pojo.TbUserScoreAccountExample;
import com.dk.service.UserScoreAccountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Deacription TODO
 * @Author 陆小军
 * @Date 2020/12/28 10:15
 * @Version 1.0
 **/
@Service
public class UserScoreAccountServiceImpl implements UserScoreAccountService {
    @Resource
    private TbUserScoreAccountMapper accountMapper;

    @Override
    public TbUserScoreAccount selectScoreAccount(String userId) {
        TbUserScoreAccountExample example = new TbUserScoreAccountExample();
        TbUserScoreAccountExample.Criteria criteria = example.createCriteria();
        criteria.andUserIdEqualTo(userId);
        List<TbUserScoreAccount> accounts = accountMapper.selectByExample(example);
        return accounts == null || accounts.size() == 0 ? null : accounts.get(0);
    }

    @Override
    public void updateScoreAccount(TbUserScoreAccount scoreAccount) {
        accountMapper.updateByPrimaryKeySelective(scoreAccount);
    }
}
